#!/usr/bin/python3
# -*- coding: utf-8 -*-
# @Time : 2021/9/17 20:08
# @Author : lenovo
# @Email : 26541796406@qq.com
# @File : top_page.py
# @Project : mryx_test
"""top页面"""
from appium.webdriver.common.mobileby import MobileBy as By
from page.base_page import BasePage
class RearchTop(BasePage):
    """top"""
    """定位器"""
    top_locator = (By.XPATH,'/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.'
                             'FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.'
                             'LinearLayout/android.widget.FrameLayout[2]/android.widget.FrameLayout/android.widget.'
                             'LinearLayout/android.widget.FrameLayout/android.webkit.WebView/android.webkit.WebView/'
                             'android.view.View/android.view.View[1]/android.view.View/android.view.View[1]/android.'
                             'view.View/android.widget.Image') # top榜
    shoop_locator = (By.XPATH,'/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.'
                             'FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.'
                             'LinearLayout/android.widget.FrameLayout[2]/android.widget.FrameLayout/android.widget.'
                             'LinearLayout/android.widget.FrameLayout/android.webkit.WebView/android.webkit.WebView/'
                             'android.view.View/android.view.View[2]/android.view.View[1]/android.view.View[4]/android.'
                             'view.View/android.view.View')  # 第一个商品+号
    get_text_locator = (By.ID, 'cn.missfresh.application:id/tv_title_bar_center_txt')  # 获取口碑文本信息
    title_locator = (By.ACCESSIBILITY_ID,'去结算(1)')
    # 具体操作
    def click_top(self):
        """点击top榜"""
        self.driver.find_element(*self.top_locator).click()
    def click_shoop(self):
        """点击top榜的第一个商品+号"""
        self.driver.find_element(*self.shoop_locator).click()
    def get_word_mouth(self):
        """获得口碑文本"""
        return self.driver.find_element(*self.get_text_locator).text
    def title_text(self):
        """获取购物车的结算文本"""
        title = self.driver.find_element(*self.title_locator)
        return title.get_attribute(name="content-desc")+"====1"